package com.speedtickets.rest.services.impl;

import java.util.List;

import com.speedtickets.rest.dao.VehicleDAO;
import com.speedtickets.rest.models.Vehicle;
import com.speedtickets.rest.services.IVehicleService;

public class VehicleService implements IVehicleService{

	private static VehicleService _instance;
    
    private static VehicleDAO _vehicleDAO = VehicleDAO.getInstance();
    
    public static VehicleService getInstance(){
        if ( _instance == null ) {
        	_instance = new VehicleService();
        }
        return _instance;
    }
    
    @Override
	public void createVehicle( Vehicle v ) throws Exception{
		_vehicleDAO.save(v);
	}
    
    @Override
    public void updateVehicle( Vehicle v ) throws Exception{
    	_vehicleDAO.update(v);
    }
    
    @Override
    public void deleteVehicle( Vehicle v ) throws Exception{
    	_vehicleDAO.delete(v);
    }
    
    @Override
    public List<Vehicle> findAllVehicles() throws Exception{
    	return _vehicleDAO.findAll();
    }
    
    @Override 
    public List<Vehicle>findAllVehicles(Integer limit, Integer offset){
    	return _vehicleDAO.findAll(limit, offset);
    }
    
    @Override 
    public Vehicle findVehicleById( Long id ){
    	return _vehicleDAO.findById(id);
    }
}
